<template>
  <div>
    <el-menu :default-active="$route.path" @select="handleSelect">
      <el-submenu index="1">
          <template v-slot:title><i class="el-icon-message"></i>领书信息</template>
          <el-menu-item-group>
            <el-menu-item v-if="userrole === 'department'|| userrole === 'admin'" index="/department">系部门</el-menu-item>
            <el-menu-item v-if="userrole === 'office'|| userrole === 'admin'" index="/office">教务处</el-menu-item>
            <el-menu-item v-if="userrole === 'class'||userrole === 'student'||userrole === 'teacher'|| userrole === 'admin'" index="/receiveAndQuery">领书查询</el-menu-item>
          </el-menu-item-group>
      </el-submenu>
      <el-submenu index="2">
        <template v-slot:title><i class="el-icon-menu"></i>教材信息</template>
        <el-menu-item-group>
            <el-menu-item index="/buyBook">购书表</el-menu-item>
            <el-menu-item index="/textbookChange">教材修改</el-menu-item>
            <el-menu-item index="/textbookInventory">教材信息</el-menu-item>
            <el-menu-item index="/textbookStockChange">库存变化</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
  import userManager from "@/UserManager";

  export default {
    data(){
      return {
        userrole:userManager.getPermissions()
      };

    },
    methods: {
      handleSelect (key, keyPath) {
        console.log(key);
       this.$router.push(key)
      }
    }
  }
</script>
